package com.creditease.mobile.util;

import android.os.AsyncTask;
import com.creditease.mobile.rss.model.RssModel;
import com.creditease.mobile.rss.servicew.FeedServices;
import com.creditease.mobile.rss.ui.HomeActivity;

import java.util.List;

public class RssDownloadTask extends AsyncTask<Object, Void, Boolean> {

    @SuppressWarnings(value = "ALL")
    @Override
    protected Boolean doInBackground(Object... objs) {
        FeedServices fs = (FeedServices) objs[0];
        List<RssModel> list = (List<RssModel>) objs[1];
        HomeActivity home = (HomeActivity) objs[2];
        for (RssModel rs : list) {
            String id = rs.id;
//                 取消
            if (!isCancelled()) {
                try {
                    fs.refrush(rs.id);
                    home.reflushCallBack(false, "true", id);
                } catch (Exception e) {
                    e.printStackTrace();
                    home.reflushCallBack(false, "false", id);
                }
            } else {
                home.reflushCallBack(true, "true", id);
                break;
            }
        }

        return false;
    }

    @Override
    protected void onCancelled() {
        super.onCancelled();
    }
}
